<?php

class Admin_Model_Resource extends Zend_Db_Table_Abstract
{
    protected $_name = 'resource';
    public function getAllData(){
        $query = $this->select()
                        ->from($this->_name);
        return $this->fetchAll($query);
    }
    public function getData($data){
        $query = $this->select()
                        ->from($this->_name);
        if(isset($data['moduleName']) && $data['moduleName']){
            $query->where('moduleName = ?',$data['moduleName']);
        }
        if(isset($data['controllerName']) && $data['controllerName']){
            $query->where('controllerName = ?',$data['controllerName']);
        }
        if(isset($data['actionName']) && $data['actionName']){
            $query->where('actionName = ?',$data['actionName']);
        }
        if(isset($data['resourceList']) && $data['resourceList']){
            $query->where('resourceId IN (?)',$data['resourceList']);
        }
        return $this->fetchAll($query);
    }
}